
<body>

<div class="warp">
    <!--header-->
    <header class="hd">
        <a href="javascript:history.go(-1)" class="l-icon only-icon">
            <i class="iconfont icon-left1"></i>
        </a>

        <p class="tit2">
            登录
        </p>
    </header>

    <div class="login-form">
        <div class="input-bar">
                <span>
                    <i class="iconfont icon-shouji"></i>
                </span>
            <input type="text" placeholder="请输入手机号码" id="mobile">
        </div>
        <div class="input-bar">
                <span>
                    <i class="iconfont icon-suo"></i>
                </span>
            <input type="password" placeholder="请输入6-12位密码" id="password">

        </div>
        <a class="login-btn" id="submit">            
			登录
        </a>
        <p class="sm-bar">
            <a href="<?php echo $base_url;?>home/account/resetPassword<?php if(!empty($back_url)) echo '?back_url=' . urlencode($back_url); ?>" class="r">忘记密码?</a>
            <a href="<?php echo $base_url;?>home/account/register<?php if(!empty($back_url)) echo '?back_url' . urlencode($back_url); ?>" class="l">注册</a>
        </p>
    </div>



</div>

<script src="<?php echo $base_url;?>/static/dist/js/base.js"></script>

<script>
    // 矫正rem
    function correctrem() {
        var rem_full_width = $("<div id='rem-test' style='width:7.5rem'></div>").appendTo($('body')).width();
        var device_width = Math.min(document.documentElement.clientWidth, 640);
        if (rem_full_width !== device_width) {
            document.documentElement.style.fontSize = (device_width / 7.5) * (device_width / rem_full_width) + 'px';
        }
        $('#rem-test').remove();
    }
    correctrem();
    $(function () {

    })


    //登录
    $('#submit').on("click",function() {
        var mobile = $('#mobile').val();
        var password = $('#password').val();

        var pattern = /^1[34578]\d{9}$/;
        if (!pattern.test(mobile)) {
            alert("请填写11位数字的正确号码"); 
            return;
        }
        if (password == "") {
            alert("请填写密码");
            return;
        }

        //帮助登录
        $.post("<?php echo $base_url; ?>home/account/checkLogin", {
            'mobile': mobile,
            'password': password
        }, function(json) {
            if (json.result == 0) {
                <?php if(empty($back_url)): ?>
                window.location.href = "<?php echo $base_url; ?>home";
                <?php else: //跳转到上一个页面?>
                window.location.href = decodeURIComponent("<?php echo urlencode($back_url); ?>");
                <?php endif; ?>
            } else  {
                alert("账号或密码错误！");
            }
            return;
        }, 'json');
    });

</script>

</body>

</html>
